home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / D-G / FORTRAN Goodies / Stack.txt < prev    next >
Encoding:
Text File  |  1992-01-03  |  857 b   |  38 lines  |  [TEXT/MPS ]

  1. c
  2. c StackGrow
  3. c
  4. c  This program demonstrates how a FORTRAN
  5. c  program can enlarge its own stack.
  6. c
  7. c  3 toolbox calls are used: StackSpace, GetApplLimit,
  8. c  and SetApplLimit.
  9. c
  10. c  Note: Language Systems FORTRAN v3.0 automatically
  11. c  adjusts the stack to 10% of the total partition
  12. c  size. The stack is initially set by the System
  13. c  to 24K on MacII-class machines.
  14. c
  15. !!mp inlines.f
  16.     program StackGrow
  17.     call addmenuitem('Stack','Report Stack Size',report)
  18.     call addmenuitem('Stack','Enlarge Stack 32K',grow32)
  19.     end
  20.     
  21.     subroutine report
  22.     write(*,*)
  23.     write(*,*) 'Size of stack is ',StackSpace()
  24.     end
  25.     
  26.     subroutine grow32
  27.     integer*4 j
  28.     j = GetApplLimit()            ! max size of heap
  29.     call SetApplLimit(int4(j-32768))
  30.     if (MemError = 0)  then
  31.         write(*,*)
  32.         write(*,*) 'Stack grow successful!'
  33.     else
  34.         write(*,*)
  35.         write(*,*) 'Stack could not be grown!!'
  36.     end if
  37.     end
  38.